<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>我的导航页</title>
    <link rel="stylesheet" href="style.css">
    <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet">
</head>
<body>
    <div class="container">
        <header>
            <h1><i class="fas fa-compass"></i> 我的导航页</h1>
            <p>个性化书签管理，让上网更高效</p>
        </header>

        <div class="search-box">
            <input type="text" id="searchInput" placeholder="搜索链接...">
            <i class="fas fa-search"></i>
        </div>

        <!-- 收藏夹按钮 -->
        <div class="favorites-section">
            <button class="favorites-btn" onclick="showFavoritesModal()">
                <i class="fas fa-heart"></i> 收藏夹
            </button>
        </div>

        <!-- 全局同步按钮 -->
        <div class="global-sync-buttons">
            <button class="global-sync-up-btn" onclick="syncAllToServer()">
                <i class="fas fa-upload"></i> 上传所有数据到服务器
            </button>
            <button class="global-sync-down-btn" onclick="syncAllFromServer()">
                <i class="fas fa-download"></i> 从服务器下载所有数据
            </button>
        </div>

        <div class="tab-container">
            <div class="tab-header">
                <div class="tab-buttons" id="tab-buttons">
                    <!-- Tab按钮将通过JavaScript动态生成 -->
                </div>
                <button class="add-tab-btn" onclick="showAddTabModal()">
                    <i class="fas fa-plus"></i> 添加Tab
                </button>
            </div>
            
            <div class="tab-content" id="tab-content">
                <!-- Tab内容将通过JavaScript动态生成 -->
            </div>
        </div>
    </div>

    <!-- 添加链接模态框 -->
    <div id="addModal" class="modal">
        <div class="modal-content">
            <span class="close">&times;</span>
            <h3>添加新链接</h3>
            <form id="addForm">
                <div class="form-group">
                    <label for="linkName">链接名称:</label>
                    <input type="text" id="linkName" required>
                </div>
                <div class="form-group">
                    <label for="linkUrl">链接地址:</label>
                    <input type="url" id="linkUrl" required>
                </div>
                <div class="form-buttons">
                    <button type="submit">添加</button>
                    <button type="button" onclick="closeModal()">取消</button>
                </div>
            </form>
        </div>
    </div>

    <!-- 编辑链接模态框 -->
    <div id="editModal" class="modal">
        <div class="modal-content">
            <span class="close">&times;</span>
            <h3>编辑链接</h3>
            <form id="editForm">
                <div class="form-group">
                    <label for="editLinkName">链接名称:</label>
                    <input type="text" id="editLinkName" required>
                </div>
                <div class="form-group">
                    <label for="editLinkUrl">链接地址:</label>
                    <input type="url" id="editLinkUrl" required>
                </div>
                <div class="form-buttons">
                    <button type="submit">更新</button>
                    <button type="button" onclick="closeEditModal()">取消</button>
                </div>
            </form>
        </div>
    </div>

    <!-- 添加Tab模态框 -->
    <div id="addTabModal" class="modal">
        <div class="modal-content">
            <span class="close">&times;</span>
            <h3>添加新Tab</h3>
            <form id="addTabForm">
                <div class="form-group">
                    <label for="tabName">Tab名称:</label>
                    <input type="text" id="tabName" required>
                </div>
                <div class="form-group">
                    <label for="tabIcon">Tab图标:</label>
                    <select id="tabIcon" required>
                        <option value="fas fa-star">⭐ 星星</option>
                        <option value="fas fa-robot">🤖 机器人</option>
                        <option value="fas fa-shopping-cart">🛒 购物车</option>
                        <option value="fas fa-play-circle">▶️ 播放</option>
                        <option value="fas fa-newspaper">📰 新闻</option>
                        <option value="fas fa-code">💻 代码</option>
                        <option value="fas fa-gamepad">🎮 游戏</option>
                        <option value="fas fa-music">🎵 音乐</option>
                        <option value="fas fa-book">📚 书籍</option>
                        <option value="fas fa-tools">🔧 工具</option>
                    </select>
                </div>
                <div class="form-buttons">
                    <button type="submit">添加</button>
                    <button type="button" onclick="closeAddTabModal()">取消</button>
                </div>
            </form>
        </div>
    </div>

    <!-- 收藏夹模态框 -->
    <div id="favoritesModal" class="modal">
        <div class="modal-content favorites-modal">
            <span class="close">&times;</span>
            <h3><i class="fas fa-heart"></i> 收藏夹管理</h3>
            
            <!-- 收藏夹工具栏 -->
            <div class="favorites-toolbar">
                <button class="add-folder-btn" onclick="showAddFolderModal()">
                    <i class="fas fa-folder-plus"></i> 新建文件夹
                </button>
                <button class="add-favorite-btn" onclick="showAddFavoriteModal()">
                    <i class="fas fa-plus"></i> 添加收藏
                </button>
            </div>

            <!-- 收藏夹内容 -->
            <div class="favorites-content" id="favoritesContent">
                <!-- 收藏夹内容将通过JavaScript动态生成 -->
            </div>
        </div>
    </div>

    <!-- 新建文件夹模态框 -->
    <div id="addFolderModal" class="modal">
        <div class="modal-content">
            <span class="close">&times;</span>
            <h3><i class="fas fa-folder-plus"></i> 新建文件夹</h3>
            <form id="addFolderForm">
                <div class="form-group">
                    <label for="folderName">文件夹名称:</label>
                    <input type="text" id="folderName" required>
                </div>
                <div class="form-group">
                    <label for="folderIcon">文件夹图标:</label>
                    <select id="folderIcon" required>
                        <option value="fas fa-folder">📁 默认文件夹</option>
                        <option value="fas fa-folder-open">📂 打开文件夹</option>
                        <option value="fas fa-bookmark">🔖 书签</option>
                        <option value="fas fa-star">⭐ 星星</option>
                        <option value="fas fa-heart">❤️ 爱心</option>
                        <option value="fas fa-gem">💎 宝石</option>
                        <option value="fas fa-crown">👑 皇冠</option>
                        <option value="fas fa-rocket">🚀 火箭</option>
                    </select>
                </div>
                <div class="form-group">
                    <label for="parentFolder">父文件夹:</label>
                    <select id="parentFolder">
                        <option value="">无（根目录）</option>
                        <!-- 父文件夹选项将通过JavaScript动态生成 -->
                    </select>
                </div>
                <div class="form-buttons">
                    <button type="submit">创建</button>
                    <button type="button" onclick="closeAddFolderModal()">取消</button>
                </div>
            </form>
        </div>
    </div>

    <!-- 添加收藏模态框 -->
    <div id="addFavoriteModal" class="modal">
        <div class="modal-content">
            <span class="close">&times;</span>
            <h3><i class="fas fa-plus"></i> 添加收藏</h3>
            <form id="addFavoriteForm">
                <div class="form-group">
                    <label for="favoriteName">收藏名称:</label>
                    <input type="text" id="favoriteName" required>
                </div>
                <div class="form-group">
                    <label for="favoriteUrl">链接地址:</label>
                    <input type="url" id="favoriteUrl" required>
                </div>
                <div class="form-group">
                    <label for="favoriteFolder">收藏位置:</label>
                    <select id="favoriteFolder" required>
                        <option value="">根目录</option>
                        <!-- 文件夹选项将通过JavaScript动态生成 -->
                    </select>
                </div>
                <div class="form-group">
                    <label for="favoriteDescription">描述 (可选):</label>
                    <textarea id="favoriteDescription" rows="3" placeholder="添加描述信息..."></textarea>
                </div>
                <div class="form-buttons">
                    <button type="submit">添加</button>
                    <button type="button" onclick="closeAddFavoriteModal()">取消</button>
                </div>
            </form>
        </div>
    </div>

    <script src="script.js"></script>
</body>
</html>
